package com.ww.aviator.func;

import com.googlecode.aviator.AviatorEvaluator;
import org.apache.commons.lang3.StringUtils;

public class UseJavaMethod {

    public static void main(String[] args) throws IllegalAccessException, NoSuchMethodException {
        AviatorEvaluator.addStaticFunctions("str", StringUtils.class);
        System.out.println(AviatorEvaluator.execute("str.isBlank('a')"));
        System.out.println(AviatorEvaluator.execute("str.isBlank(' ')"));
        System.out.println(AviatorEvaluator.execute("str.isBlank('')"));

        AviatorEvaluator.addInstanceFunctions("s", String.class);
        System.out.println(AviatorEvaluator.execute("s.indexOf('hello', 'l')"));
    }
}
